.TH E1432_INIT_MEASURE 3 E1432
.SH NAME
e1432_init_measure \- Initialize measurement, move E1432s to IDLE state
.IX e1432_init_measure(3) 3
.IX e1432_init_measure_to_booted(3) 3
.IX e1432_init_measure_finish(3) 3
.SH SYNOPSIS
.cS
SHORTSIZ16 e1432_init_measure(E1432ID hw, SHORTSIZ16 ID)         
SHORTSIZ16 e1432_init_measure_to_booted(E1432ID hw, SHORTSIZ16 ID,
                                        SHORTSIZ16 wait_after)
SHORTSIZ16 e1432_init_measure_finish(E1432ID hw, SHORTSIZ16 ID,
                                     SHORTSIZ16 wait_after)
.cE
.SH DESCRIPTION

\fIe1432_init_measure\fR places all modules in the group into the idle
state.  The modules can be in any state before the call so
\fIe1432_init_measure\fR can be used to abort a current measurement.

After the call to \fIe1432_init_measure\fR completes successfully, the
E1432 will ready for arming and triggering (see
\fIe1432_arm_measure\fR and \fIe1432_trigger_measure\fR).  If auto arm
or auto trigger are on, the hardware may proceed beyond the idle state
without further intervention.

Overload flags are reset by \fIe1432_init_measure\fR, see
\fIe1432_check_overloads\fR.

\fIe1432_init_measure_to_booted\fR is for the special case of the
library user wanting to initialize the modules half way, (to booted
state), performing some communications with other hardware on the VXI
bus, and then finishing the measurement initialization with
\fIe1432_init_measure_finish\fR.  Most users will need only the
\fIe1432_init_measure\fR to perform data collection with the E1432.

\fIhw\fR must be the result of a successful call to
\fIe1432_assign_channel_numbers\fR, and specifies the group of
hardware to talk to.

\fIID\fR is either the ID of a group of channels that was obtained with a
call to \fIe1432_create_channel_group\fR, or the ID of a single channel.

\fIwait_after\fR is used only with \fIe1432_init_measure_to_booted\fR
and \fIe1432_init_measure_finish\fR.  If this is set to non-zero, the
function will not return until the module has completed moving to the
\fBBOOTED\fR state (for \fIe1432_init_measure_to_booted\fR) or the
\fBIDLE\fR state (for \fIe1432_init_measure_finish\fR).  If it is
zero, then the functions will return as soon as they are done
requesting that the measurement state move, not waiting for the module
to actually complete moving to the next measurement state.

The measurement itself consists of two phases, the measurement
initialization, and the measurement loop.  Each of these phases
consists of several states, through which the measurement progresses.
The transition from one state to the next is tied to a transition in
the SYNC line (one of the TTLTRG lines on the VXI backplane).  This
SYNC line is "wired-ORed" such that all E1432s in a multiple module
system must release it for it to go high.  Only one E1432 is required
to pull the SYNC line low.  In a single E1432 system, the SYNC line is
local to the module and is not tied into a TTLTRG line on the VXI
backplane.

.ne 10

The measurement initialization states, and the corresponding SYNC line
transitions (with 'H' for high, 'L' for Low) are:

.cS
  TESTED ---> BOOTING ---> BOOTED ---> SYNC ---> PRE_ARM ---> IDLE
         H->L         L->H        H->L                       L->H
.cE

.ne 3
This complete measurement sequence initialization, from \fBTESTED\fR,
through \fBBOOTING\fR, \fBBOOTED\fR, \fBSYNC\fR, \fBPRE_ARM\fR, and 
ultimately \fBIDLE\fR, can be performed with a call to the function 
\fIe1432_init_measure\fR.

.ne 8
The progression of measurement loop states and the corresponding
SYNC line transitions are:

.cS
        -------------------------------------------------------
        |                                                      |
     ------> IDLE -----> ARM -----> TRIGGER -----> MEASURE -----
                   H->L       L->H           H->L           L->H 
.cE

In the \fBIDLE\fR state the E1432 clears the FIFO An E1432 remains in
the \fBIDLE\fR state until it sees a high to low transition of the
SYNC line.  If any of the E1432 is programmed for auto arming, with
\fIe1432_set_auto_arm\fR, the SYNC line immediately goes low, exiting
the \fBIDLE\fR state for the ARM state.  The E1432 may also be moved
to the ARM state by an explicit call to the function,
\fIe1432_arm_measure\fR.

Upon entering the \fBARM\fR state, the E1432 starts saving new data in
it's FIFO.  It remains in the \fBARM\fR state until the SYNC signal
goes high.  If an E1432 is programmed with a pre-trigger delay, it
collects enough data samples to satify this pre-trigger delay, and
then releases the SYNC line.  If no pre-trigger delay has been
programmed, the SYNC line goes high immediately.  When all E1432s in a
system have released the SYNC line allowing it to go high, a
transition to the \fBTRIGGER\fR state occurs.

Upon entering the \fBTRIGGER\fR state an E1432 continues collecting
data into the FIFO, discarding any data prior to the pre-trigger
delay.  An E1432 remains in the \fBTRIGGER\fR state until it sees a
high to low transition of the SYNC line.  The SYNC line is pulled low
by any E1432 which encounters a trigger condition and is programmed to
pull the SYNC line.  If any E1432 is programmed for auto triggering,
with \fIe1432_set_auto_trigger\fR, the SYNC line goes low immediately,
exiting the \fBTRIGGER\fR state.  The SYNC line may also be pulled low
by an explicit call to the function, \fIe1432_trigger_measure\fR.

Upon entering the \fBMEASURE\fR state an E1432 continues to collect
data.  The E1432 also presents the first data from the FIFO to the
selected output port, making it available to the controller to read.
The E1432 holds the SYNC line low as long as it it actively collecting
data.

\fBNote:\fR When in the one of the RPM arming/triggering modes in a
multiple module system, the slave modules move from state to state in
a different manner.  They change states in response to a command
passed from the master through the host computer.  See
\fIe1432_set_arm_mode\fR for details of this behavior.

In block mode the E1432 module stops taking data as soon as a block of
data has been collected, including any programmed pre or post trigger
delays.  In continuous mode, the E1432 stops taking data when the FIFO
overflows.  After the FIFO overflow, the E1432 will remain in the
\fBMEASURE\fR state, not taking data, until the FIFO is emptied, and
then it will move to the \fBTESTED\fR state.  For more information
about data modes, see the \fIe1432_set_data_mode\fR manual page.

A channel group that spans more than one module will need to be
configured to use the TTLTRG trigger lines on the VXI bus for
inter-module communication.  This configuration is automatically
performed in the \fIe1432_init_measure\fR call unless defeated using
\fIe1432_set_auto_group_meas\fI.  See the
\fIe1432_set_auto_group_meas\fR manual page for details on what setups
are done automatically.

There are 4 pairs of VXIBUS TTLTRG lines that can be used for
multi-module synchronization.  The pair is selected using the
\fIe1432_set_ttltrg_clock\fR and \fIe1432_set_ttltrg_satrg\fR (be sure
to use a group ID for those functions, to ensure that all modules in
the group are set to the same two TTLTRG lines).

After a multi-module measurement has completed, the modules are left
connected to the VXI TTLTRG lines.  This helps subsequent multi-module
measurements start more quickly.  However, it can also cause problems
if a module (call it module 'A') is driving the TTL trigger lines and
a different group is started which also drives the TTLTRG lines, and
that different group does not include module 'A'.  Module 'A' will
conflict and prevent the different group from functioning properly.
In this case a call to \fIe1432_finish_measure\fR for module 'A' will
disconnect module 'A' from the TTLTRG lines, allowing the new group to
function properly.

Note that if the new group includes all modules of the old group, the
conflict will not occur since \fIe1432_init_measure\fR will reset
all modules as needed.  Also note that single module groups do not
drive the TTLTRG lines, so single modules groups are immune from
causing or receiving this conflict.

At the start of a measurement that uses local bus, it is important to
properly reset the local bus before starting the measurement.  Before
resetting the local bus, make sure all E1432 modules are no longer
running any previous measurement, by calling
\fIe1432_reset_measure\fR.  Then the local bus interface on all VXI
cards must be reset, and then they must all be un-reset.  The order in
which the cards must be reset and un-reset is important.  After all
that, the measurement can be started with \fIe1432_init_measure\fR.

.SH "RESET VALUE"
Not applicable.
.SH "RETURN VALUE"
Return 0 if successful, a (negative) error number otherwise.
.SH "SEE ALSO"
.na
e1432_arm_measure, e1432_trigger_measure, e1432_finish_measure,
e1432_reset_measure, e1432_check_overloads, e1432_reset_lbus,
e1432_set_auto_group_meas, e1432_set_ttltrg_clock,
e1432_set_ttltrg_satrg
.ad
